{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 共享单车数据预测——线性回归分析\n",
    "数据说明： Capital Bikeshare （美国Washington, D.C.的一个共享单车公司）提供的共享单车数据。数据包含每天的日期、天气等信息，需要预测每天的共享单车骑行量。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1、导入必要的工具包"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np  # 矩阵操作\n",
    "import pandas as pd # SQL数据处理\n",
    "\n",
    "from sklearn.metrics import r2_score  #评价回归预测模型的性能\n",
    "\n",
    "import matplotlib.pyplot as plt   #画图\n",
    "import seaborn as sns\n",
    "\n",
    "# 图形出现在Notebook里而不是新窗口\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2、数据探索"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2.1 读取数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>instant</th>\n",
       "      <th>dteday</th>\n",
       "      <th>season</th>\n",
       "      <th>yr</th>\n",
       "      <th>mnth</th>\n",
       "      <th>holiday</th>\n",
       "      <th>weekday</th>\n",
       "      <th>workingday</th>\n",
       "      <th>weathersit</th>\n",
       "      <th>temp</th>\n",
       "      <th>atemp</th>\n",
       "      <th>hum</th>\n",
       "      <th>windspeed</th>\n",
       "      <th>casual</th>\n",
       "      <th>registered</th>\n",
       "      <th>cnt</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.344167</td>\n",
       "      <td>0.363625</td>\n",
       "      <td>0.805833</td>\n",
       "      <td>0.160446</td>\n",
       "      <td>331</td>\n",
       "      <td>654</td>\n",
       "      <td>985</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>2011-01-02</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.363478</td>\n",
       "      <td>0.353739</td>\n",
       "      <td>0.696087</td>\n",
       "      <td>0.248539</td>\n",
       "      <td>131</td>\n",
       "      <td>670</td>\n",
       "      <td>801</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>2011-01-03</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.196364</td>\n",
       "      <td>0.189405</td>\n",
       "      <td>0.437273</td>\n",
       "      <td>0.248309</td>\n",
       "      <td>120</td>\n",
       "      <td>1229</td>\n",
       "      <td>1349</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>2011-01-04</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.200000</td>\n",
       "      <td>0.212122</td>\n",
       "      <td>0.590435</td>\n",
       "      <td>0.160296</td>\n",
       "      <td>108</td>\n",
       "      <td>1454</td>\n",
       "      <td>1562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>2011-01-05</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.226957</td>\n",
       "      <td>0.229270</td>\n",
       "      <td>0.436957</td>\n",
       "      <td>0.186900</td>\n",
       "      <td>82</td>\n",
       "      <td>1518</td>\n",
       "      <td>1600</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   instant      dteday  season  yr  mnth  holiday  weekday  workingday  \\\n",
       "0        1  2011-01-01       1   0     1        0        6           0   \n",
       "1        2  2011-01-02       1   0     1        0        0           0   \n",
       "2        3  2011-01-03       1   0     1        0        1           1   \n",
       "3        4  2011-01-04       1   0     1        0        2           1   \n",
       "4        5  2011-01-05       1   0     1        0        3           1   \n",
       "\n",
       "   weathersit      temp     atemp       hum  windspeed  casual  registered  \\\n",
       "0           2  0.344167  0.363625  0.805833   0.160446     331         654   \n",
       "1           2  0.363478  0.353739  0.696087   0.248539     131         670   \n",
       "2           1  0.196364  0.189405  0.437273   0.248309     120        1229   \n",
       "3           1  0.200000  0.212122  0.590435   0.160296     108        1454   \n",
       "4           1  0.226957  0.229270  0.436957   0.186900      82        1518   \n",
       "\n",
       "    cnt  \n",
       "0   985  \n",
       "1   801  \n",
       "2  1349  \n",
       "3  1562  \n",
       "4  1600  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# path to where the data lies\n",
    "#dpath = './data/'\n",
    "data = pd.read_csv(\"day.csv\")\n",
    "\n",
    "#通过观察前5行，了解数据每列（特征）的概况\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2.2 数据基本信息\n",
    "样本数目、特征维数\n",
    "每个特征的类型、空值样本的数目、数据类型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(731, 16)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2.3 数据探索\n",
    "请见另一个文件：1week_0_Explore.pynb\n",
    "\n",
    "对数据的探索有助于我们在第三步中根据数据的特点选择合适的模型类型"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2.4 数据准备"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Index(['holiday', 'weekday', 'workingday', 'weathersit', 'temp', 'atemp',\n",
      "       'hum', 'windspeed'],\n",
      "      dtype='object')\n"
     ]
    }
   ],
   "source": [
    "# 从原始数据中分离输入特征x和输出y\n",
    "y = data['cnt'].values\n",
    "\n",
    "#分离一下无用的特征\n",
    "data_remove = data.drop('instant',axis = 1)\n",
    "data_remove = data_remove.drop('dteday',axis = 1)\n",
    "data_remove = data_remove.drop('season',axis = 1)\n",
    "data_remove = data_remove.drop('yr',axis = 1)\n",
    "data_remove = data_remove.drop('mnth',axis = 1)\n",
    "data_remove = data_remove.drop('casual',axis = 1)\n",
    "data_remove = data_remove.drop('registered',axis = 1)\n",
    "X = data_remove.drop('cnt',axis = 1)\n",
    "\n",
    "#用于后续显示权重系数对应的特征\n",
    "columns = X.columns\n",
    "print(columns)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(584, 8)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#将数据分割训练数据与测试数据\n",
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "# 随机采样20%的数据构建测试样本，其余作为训练样本\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=None, test_size=0.2)\n",
    "X_train.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2.5 数据预处理／特征工程\n",
    "特征工程是实际任务中特别重要的环节。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\YuGo\\Anaconda3\\lib\\site-packages\\sklearn\\utils\\validation.py:475: DataConversionWarning: Data with input dtype int64 was converted to float64 by StandardScaler.\n",
      "  warnings.warn(msg, DataConversionWarning)\n",
      "C:\\Users\\YuGo\\Anaconda3\\lib\\site-packages\\sklearn\\utils\\validation.py:475: DataConversionWarning: Data with input dtype int64 was converted to float64 by StandardScaler.\n",
      "  warnings.warn(msg, DataConversionWarning)\n",
      "C:\\Users\\YuGo\\Anaconda3\\lib\\site-packages\\sklearn\\utils\\validation.py:475: DataConversionWarning: Data with input dtype int64 was converted to float64 by StandardScaler.\n",
      "  warnings.warn(msg, DataConversionWarning)\n"
     ]
    }
   ],
   "source": [
    "# 数据标准化\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "\n",
    "# 分别初始化对特征和目标值的标准化器\n",
    "ss_X = StandardScaler()\n",
    "ss_y = StandardScaler()\n",
    "\n",
    "# 分别对训练和测试数据的特征以及目标值进行标准化处理\n",
    "X_train = ss_X.fit_transform(X_train)\n",
    "X_test = ss_X.transform(X_test)\n",
    "\n",
    "#对y做标准化不是必须\n",
    "#对y标准化的好处是不同问题的w差异不太大，同时正则参数的范围也有限\n",
    "y_train = ss_y.fit_transform(y_train.reshape(-1, 1))\n",
    "y_test = ss_y.transform(y_test.reshape(-1, 1))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3、确定模型类型"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3.1 尝试缺省参数的线性回归"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>columns</th>\n",
       "      <th>coef</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>atemp</td>\n",
       "      <td>[0.3414704504662848]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>temp</td>\n",
       "      <td>[0.25995770984583483]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>weekday</td>\n",
       "      <td>[0.05959606113987586]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>workingday</td>\n",
       "      <td>[0.03703338474130662]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>holiday</td>\n",
       "      <td>[-0.027165022849018075]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>weathersit</td>\n",
       "      <td>[-0.1224343063929487]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>windspeed</td>\n",
       "      <td>[-0.14798511879908544]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>hum</td>\n",
       "      <td>[-0.16007614239866622]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      columns                     coef\n",
       "5       atemp     [0.3414704504662848]\n",
       "4        temp    [0.25995770984583483]\n",
       "1     weekday    [0.05959606113987586]\n",
       "2  workingday    [0.03703338474130662]\n",
       "0     holiday  [-0.027165022849018075]\n",
       "3  weathersit    [-0.1224343063929487]\n",
       "7   windspeed   [-0.14798511879908544]\n",
       "6         hum   [-0.16007614239866622]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 线性回归\n",
    "#class sklearn.linear_model.LinearRegression(fit_intercept=True, normalize=False, copy_X=True, n_jobs=1)\n",
    "from sklearn.linear_model import LinearRegression\n",
    "\n",
    "# 使用默认配置初始化\n",
    "lr = LinearRegression()\n",
    "\n",
    "# 训练模型参数\n",
    "lr.fit(X_train, y_train)\n",
    "\n",
    "# 预测\n",
    "y_test_pred_lr = lr.predict(X_test)\n",
    "y_train_pred_lr = lr.predict(X_train)\n",
    "\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(columns), \"coef\":list((lr.coef_.T))})\n",
    "fs.sort_values(by=['coef'],ascending=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3.1.1 模型评价"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of LinearRegression on test is 0.49831584608815194\n",
      "The r2 score of LinearRegression on train is 0.4757195027526391\n"
     ]
    }
   ],
   "source": [
    "# 使用r2_score评价模型在测试集和训练集上的性能，并输出评估结果\n",
    "#测试集\n",
    "print ('The r2 score of LinearRegression on test is', r2_score(y_test, y_test_pred_lr))\n",
    "#训练集\n",
    "print ('The r2 score of LinearRegression on train is', r2_score(y_train, y_train_pred_lr))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAekAAAFsCAYAAADos0H8AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAHKhJREFUeJzt3XuUVeWZ5/HvEyzFFsWghUEIAY0a7wVdEhl7DBETTTBiZnJzvC4vOEZ7mUsnRjNpK3bSnSyNdhyNHRKvkcRbYptJ2mkNLe1ljDYYohDMQKtMQIKo8YLGKPDMH2dDl1BFHapOUS+c72ets+rsvd+993POhvrVu6+RmUiSpPK8baALkCRJXTOkJUkqlCEtSVKhDGlJkgplSEuSVChDWpKkQhnSanoRMT8iJg10HQMpIj4aEb+LiJURMW4zrndlROzRzbRTI+KBBq3n6Yg4shHLkjYnQ1pbta5+Oa//yz8z98/MWT0sZ0xEZERs00+lDrRLgXMzc0hm/mr9idVnf7UK1aURcVlEDOrrSqv1PdnX5UhbK0NaKkAB4f8uYH4PbQ7OzCHA+4BPAqf1e1VSkzOk1fQ697YjYkJEzI6IlyNieURcVjW7r/r5YtWbnBgRb4uI/xERiyPi2Yi4MSKGdlruydW05yPiK+utpyMibo+ImyLiZeDUat0PRcSLEbEsIq6MiG07LS8j4tMRsTAiXomIv4mIPat5Xo6IWzu3X+8zdllrRGwXESuBQcCvI+Lfe/q+MnMR8CDQ1mn5QyPimqrupRHxtbU97Yh4d0T8a0S8FBHPRcQt632md1fvd4mIn1af5RFgz07tNtiTERGzIuKM6v2eEfEv1Xf9XETMiIidu/kuutvGUnEMaemtvg18OzN3ohYSt1bjD69+7lzton0IOLV6vR/YAxgCXAkQE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+858D8NJLL71lOcuWLeOiiy5izpw5DB06lPe///2MGzduo+sePHgwd9xxBzvttBPPPfcchx56KMcee+xbTsD64Q9/yFFHHcWXv/xlVq9ezWuvvdarz/nEE09w77338sorr7DPPvtw9tlns2jRIm655RYefPBBWlpa+PSnP82MGTM4+eST+frXv86wYcNYvXo1kydP5rHHHuOggw5aV/cDDzzQqzo2pq6edESMAqYA36+GAzgCWPtn0A3AcQ2vTpK02fzxj3+kra2NXXbZhRdeeIEPfOADQC2k7777bsaNG8f48eN54oknWLhwIQceeCC/+MUvOP/887n//vsZOnToW5b38MMPM2nSJFpbW9l222355Cc/2WMNmcmFF17IQQcdxJFHHsnSpUtZvnz5W9occsghXHfddXR0dPD444+z44479urzTpkyhe22245dd92V4cOHs3z5cmbOnMmcOXM45JBDaGtrY+bMmTz55JMA3HrrrYwfP55x48Yxf/58fvOb36xbVj2frTfq3d3998AXgTXV8C7Ai5m5qhpeAoxscG2SpM1o7THpxYsX88Ybb6w7Jp2ZXHDBBcydO5e5c+eyaNEiTj/9dPbee2/mzJnDgQceyAUXXMDFF1+8wTK7uwRpm222Yc2aNeuW/8YbbwAwY8YMVqxYwZw5c5g7dy677bbbBtcZH3744dx3332MHDmSk046iRtvvLFXn3e77bZb937QoEGsWrWKzOSUU05Z91l/+9vf0tHRwVNPPcWll17KzJkzeeyxx5gyZcpb6tphhx16VUNPetzdHRHHAM9m5pyImLR2dBdNs5v5pwHTAEaPHt3LMqUtQ71n5Db6zF2pkYYOHcoVV1zB1KlTOfvssznqqKP4yle+wgknnMCQIUNYunQpLS0trFq1imHDhnHiiScyZMgQrr/++rcs573vfS/nnXcezz//PDvttBO33XYbBx98MFA7jjtnzhw+8YlPcOedd/Lmm28CtV3mw4cPp6WlhXvvvZfFizd8ouPixYsZOXIkZ555Jq+++iqPPvooJ598ckM+++TJk5k6dSqf/exnGT58OC+88AKvvPIKL7/8MjvssANDhw5l+fLl3HXXXUyaNKkh69yYeo5JHwYcGxEfBgZTOyb998DOEb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ICp61bAUjOLiCHAj4HPZObLfV1e04d0Zh65sekRcQpwDDA5vai83/W0PTSgvBWwtBER0UItoGdk5k8asUx3d29ERBwNnA8cm5mvDXQ90gDzVsBSNyIigGuABZl5WaOWa0hv3JXAjsA9ETE3Iv5hoAtqZhHx0YhYAkwEfh4R/zzQNTWT6iTKtbcCXgDcupXdCniLEhE/Ah4C9omIJRFx+kDX1OQOA04CjqjyYm5EfLivC/W2oJIkFcqetCRJhTKkJUkqlCEtSVKhDGlJkgplSEuSVChDWpKkQhnSkiQV6v8Dh3m8tfZxRxUAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 504x360 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#在训练集上观察预测残差的分布，看是否符合模型假设：噪声为0均值的高斯噪声\n",
    "f, ax = plt.subplots(figsize=(7, 5)) \n",
    "f.tight_layout() \n",
    "ax.hist(y_train - y_train_pred_lr,bins=40, label='Residuals Linear', color='b', alpha=.5); \n",
    "ax.set_title(\"Histogram of Residuals\") \n",
    "ax.legend(loc='best');"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARgAAADQCAYAAADcQn7hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJztnXl0lOXVwH93hkmYIBBWlaholWJlX1SUqki1oFYEVEDRI9Vq3W1VFLVWab9WPrHCp/ZQLa5I3ZEqsYqCWlFBQZaISKuoSEAWIUEghMnkfn/MTJgksyYz804m93fOnMzy5n1uJvPeuc9dRVUxDMNIBy6nBTAMI3cxBWMYRtowBWMYRtowBWMYRtowBWMYRtowBWMYRtowBWMYRtowBWMYRtowBWMYRtp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YgjEMI22YgjEMI22YgjEMI2006UQ7I/2ISAdgQfDhQYAf2Bp8fFywrsgJuYYCe1R1sRPrG4lhCsaIiap+D/QFEJG7gV2qel/4McGEMVHV6vpnSBtDCYzXMAWTxdgWyWgQInJUsMbpb8AnwKEiUhb2+jgRmRm8f6CIzBGRpcG+I4MinK+FiEwLnnOViFwdfH6DiNwtIsuDz/9YRI4EfgVMDPb7OTEzf7WRLGbBGI3hGOCXqnqliMT6LD0A3Kuqi4NVw/OAusV0VwFdgD6q6heR9mGvbVbVfiJyPXBjcL2ZwDZVnZ6yv8ZIOaZgjMbwpap+nMBxpwHdAzspANqJiFdVK+ocM11V/QCqGt6vJVQEuAw4s5EyGxnEFIzRGHaH3a+mdkuGlmH3hfgOYSF6+4bK4E8/9pltUpgPxkgJQQfvDhHpJiIuYFTYy28B14QeiEjfCKeYD1wlIu7gMe0jHBPODwTaTBpZjCkYI5XcCrxOIKy9Iez5a4DBQSftZ8DlEX73YeA7YJWIrATGxFnrn8CYoPPXnLxZilVTG4aRNsyCMQwjbZiCMQwjbZiCMQwjbZiCMQwjbZiCMQwjbZiCMQwjbZiCMQwjbfw/q8+LVfezxFEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 288x216 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#还可以观察预测值与真值的散点图\n",
    "plt.figure(figsize=(4, 3))\n",
    "plt.scatter(y_train, y_train_pred_lr)\n",
    "plt.plot([-3, 3], [-3, 3], '--k')   #数据已经标准化，3倍标准差即可\n",
    "plt.axis('tight')\n",
    "plt.xlabel('True cnt')\n",
    "plt.ylabel('Predicted cnt')\n",
    "plt.tight_layout()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of RidgeCV on test is 0.4939879025732826\n",
      "The r2 score of RidgeCV on train is 0.47227937418192034\n"
     ]
    }
   ],
   "source": [
    "#岭回归／L2正则\n",
    "#class sklearn.linear_model.RidgeCV(alphas=(0.1, 1.0, 10.0), fit_intercept=True, \n",
    "#                                  normalize=False, scoring=None, cv=None, gcv_mode=None, \n",
    "#                                  store_cv_values=False)\n",
    "from sklearn.linear_model import  RidgeCV\n",
    "\n",
    "#设置超参数（正则参数）范围\n",
    "alphas = [ 0.01, 0.1, 1, 10,100]\n",
    "#n_alphas = 20\n",
    "#alphas = np.logspace(-5,2,n_alphas)\n",
    "\n",
    "#生成一个RidgeCV实例\n",
    "ridge = RidgeCV(alphas=alphas, store_cv_values=True)  \n",
    "\n",
    "#模型训练\n",
    "ridge.fit(X_train, y_train)    \n",
    "\n",
    "#预测\n",
    "y_test_pred_ridge = ridge.predict(X_test)\n",
    "y_train_pred_ridge = ridge.predict(X_train)\n",
    "\n",
    "\n",
    "# 评估，使用r2_score评价模型在测试集和训练集上的性能\n",
    "print ('The r2 score of RidgeCV on test is', r2_score(y_test, y_test_pred_ridge))\n",
    "print ('The r2 score of RidgeCV on train is', r2_score(y_train, y_train_pred_ridge))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZIAAAEKCAYAAAA4t9PUAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3Xl4VPXZ//H3nUkme4BAgLDJKhhkTcBSrbXWtloV3IsLiGLdHmo3bbF9Wp9H2z5aa2ut1hVQccOitmht3a3VX0USVtkUcQEBCfsSyPr9/TEnYYyBTEhOTjLzeV3XXJn5nmXuM0A+nGXuY845REREDldS0AWIiEj7piAREZFmUZCIiEizKEhERKRZFCQiItIsChIREWkWBYmIiDSLr0FiZieb2WozW2Nm0xu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aRYFicghmNmeZi4/1/vW/KHmed0O0Tk51nnqzZ9nZv+MdX6R5lCQiPjE67UUcs6tbe33ds6VAhvN7NjWfm9JPAoSkRh43wi+1czetcj9Xr7jjSd5rTCWm9lzZva8mZ3jLXYhUd+oN7O7vQaRy83sfw/yPnvM7DYzW2hmr5hZXtTkc83sHTN7z8y+4s3f18z+7c2/0My+HDX/X70aRHylIBGJzVnASGAEcBJwq9c+5CygLzAMuAwYF7XMsUBJ1OufO+eKgOHAV81seAPvkwksdM6NBv4F3BA1Ldk5Nxb4QdT4ZuAb3vzfAe6Imr8Y+ErTN1WkaRKyaaPIYTiOSBfcauAzM/sXMMYb/4tzrgbYZGavRS2TD5RGvT7Pa+2f7E0rINLWIloNMMd7/ggQ3YCv9nkJkfACSAHuNLORQDVwZNT8m4m0qhHxlYJEJDYHu8nUoW4+tY9IDy3MrB9wLTDGObfdzB6sndaI6B5G5d7Pag782/0hkR5nI4gcYdgfNX+aV4OIr3RoSyQ2bwDfMbOQd97ieCLNFd8kcuOnJDPrRuR2q7VWAgO95znAXmCnN98pB3mfJCLdfwEu8NZ/KB2Ajd4e0SQit8+tdSRto/uzxDntkYjE5hki5z+WENlL+IlzbpOZPQV8ncgv7PeI3Jlup7fM34kEy8vOuSVmtohId9i1wFsHeZ+9wFAzK/HW851G6voz8JSZnUukO+/eqGlf82oQ8ZW6/4o0k5lluchd8ToT2Us51guZdCK/3I/1zq3Esq49zrmsFqrrDWCCc257S6xP5GC0RyLSfM+ZWUcgDNzknNsE4JzbZ2Y3ELk39ietWZB3+O33ChFpDdojERGRZtHJdhERaRYFiYiINIuCREREmkVBIiIizaIgERGRZlGQiIhIs/x/hJSkcR0TvkMAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 100.0\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>columns</th>\n",
       "      <th>coef_lr</th>\n",
       "      <th>coef_ridge</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>atemp</td>\n",
       "      <td>[0.3414704504662848]</td>\n",
       "      <td>[0.27902244130325116]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>temp</td>\n",
       "      <td>[0.25995770984583483]</td>\n",
       "      <td>[0.27453834808757577]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>weekday</td>\n",
       "      <td>[0.05959606113987586]</td>\n",
       "      <td>[0.052878680766823116]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>workingday</td>\n",
       "      <td>[0.03703338474130662]</td>\n",
       "      <td>[0.032779751173616464]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>holiday</td>\n",
       "      <td>[-0.027165022849018075]</td>\n",
       "      <td>[-0.02439314298027631]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>weathersit</td>\n",
       "      <td>[-0.1224343063929487]</td>\n",
       "      <td>[-0.12784764573223628]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>windspeed</td>\n",
       "      <td>[-0.14798511879908544]</td>\n",
       "      <td>[-0.12773419510294065]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>hum</td>\n",
       "      <td>[-0.16007614239866622]</td>\n",
       "      <td>[-0.12687929764710046]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      columns                  coef_lr              coef_ridge\n",
       "5       atemp     [0.3414704504662848]   [0.27902244130325116]\n",
       "4        temp    [0.25995770984583483]   [0.27453834808757577]\n",
       "1     weekday    [0.05959606113987586]  [0.052878680766823116]\n",
       "2  workingday    [0.03703338474130662]  [0.032779751173616464]\n",
       "0     holiday  [-0.027165022849018075]  [-0.02439314298027631]\n",
       "3  weathersit    [-0.1224343063929487]  [-0.12784764573223628]\n",
       "7   windspeed   [-0.14798511879908544]  [-0.12773419510294065]\n",
       "6         hum   [-0.16007614239866622]  [-0.12687929764710046]"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mse_mean = np.mean(ridge.cv_values_, axis = 0)\n",
    "plt.plot(np.log10(alphas), mse_mean.reshape(len(alphas),1)) \n",
    "\n",
    "#这是为了标出最佳参数的位置，不是必须\n",
    "#plt.plot(np.log10(ridge.alpha_)*np.ones(3), [0.28, 0.29, 0.30])\n",
    "\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()\n",
    "\n",
    "print ('alpha is:', ridge.alpha_)\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(columns), \"coef_lr\":list((lr.coef_.T)), \"coef_ridge\":list((ridge.coef_.T))})\n",
    "fs.sort_values(by=['coef_lr'],ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of LassoCV on test is 0.4976622423904308\n",
      "The r2 score of LassoCV on train is 0.47559379515164024\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\YuGo\\Anaconda3\\lib\\site-packages\\sklearn\\linear_model\\coordinate_descent.py:1094: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n",
      "  y = column_or_1d(y, warn=True)\n"
     ]
    }
   ],
   "source": [
    "#### Lasso／L1正则\n",
    "# class sklearn.linear_model.LassoCV(eps=0.001, n_alphas=100, alphas=None, fit_intercept=True, \n",
    "#                                    normalize=False, precompute=’auto’, max_iter=1000, \n",
    "#                                    tol=0.0001, copy_X=True, cv=None, verbose=False, n_jobs=1,\n",
    "#                                    positive=False, random_state=None, selection=’cyclic’)\n",
    "from sklearn.linear_model import LassoCV\n",
    "\n",
    "#设置超参数搜索范围\n",
    "#alphas = [ 0.01, 0.1, 1, 10,100]\n",
    "\n",
    "#生成一个LassoCV实例\n",
    "#lasso = LassoCV(alphas=alphas)  \n",
    "lasso = LassoCV()  \n",
    "\n",
    "#训练（内含CV）\n",
    "lasso.fit(X_train, y_train)  \n",
    "\n",
    "#测试\n",
    "y_test_pred_lasso = lasso.predict(X_test)\n",
    "y_train_pred_lasso = lasso.predict(X_train)\n",
    "\n",
    "\n",
    "# 评估，使用r2_score评价模型在测试集和训练集上的性能\n",
    "print ('The r2 score of LassoCV on test is', r2_score(y_test, y_test_pred_lasso))\n",
    "print ('The r2 score of LassoCV on train is', r2_score(y_train, y_train_pred_lasso))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEKCAYAAAD9xUlFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3Xl83HW97/HXJ1vTNd1SuqQrDW2ptFRDAQGFi0D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UP0AAAAV0lEQVTc81skNNpSEDna42Y2GigAbnX3fQDu3mxmN5O4f/DOdBYU7OL6dwWCpIO2FEREpIs6mkVEpItCQUREuigURESki0JBRES6KBRERKSLQkFERLr8J9yOOjGWaNH0AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 0.004716313265995606\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>columns</th>\n",
       "      <th>coef_lr</th>\n",
       "      <th>coef_ridge</th>\n",
       "      <th>coef_lasso</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>atemp</td>\n",
       "      <td>[0.3414704504662848]</td>\n",
       "      <td>[0.27902244130325116]</td>\n",
       "      <td>0.338881</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>temp</td>\n",
       "      <td>[0.25995770984583483]</td>\n",
       "      <td>[0.27453834808757577]</td>\n",
       "      <td>0.258295</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>weekday</td>\n",
       "      <td>[0.05959606113987586]</td>\n",
       "      <td>[0.052878680766823116]</td>\n",
       "      <td>0.055673</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>workingday</td>\n",
       "      <td>[0.03703338474130662]</td>\n",
       "      <td>[0.032779751173616464]</td>\n",
       "      <td>0.033285</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>holiday</td>\n",
       "      <td>[-0.027165022849018075]</td>\n",
       "      <td>[-0.02439314298027631]</td>\n",
       "      <td>-0.023631</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>weathersit</td>\n",
       "      <td>[-0.1224343063929487]</td>\n",
       "      <td>[-0.12784764573223628]</td>\n",
       "      <td>-0.121343</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>windspeed</td>\n",
       "      <td>[-0.14798511879908544]</td>\n",
       "      <td>[-0.12773419510294065]</td>\n",
       "      <td>-0.143046</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>hum</td>\n",
       "      <td>[-0.16007614239866622]</td>\n",
       "      <td>[-0.12687929764710046]</td>\n",
       "      <td>-0.154900</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      columns                  coef_lr              coef_ridge  coef_lasso\n",
       "5       atemp     [0.3414704504662848]   [0.27902244130325116]    0.338881\n",
       "4        temp    [0.25995770984583483]   [0.27453834808757577]    0.258295\n",
       "1     weekday    [0.05959606113987586]  [0.052878680766823116]    0.055673\n",
       "2  workingday    [0.03703338474130662]  [0.032779751173616464]    0.033285\n",
       "0     holiday  [-0.027165022849018075]  [-0.02439314298027631]   -0.023631\n",
       "3  weathersit    [-0.1224343063929487]  [-0.12784764573223628]   -0.121343\n",
       "7   windspeed   [-0.14798511879908544]  [-0.12773419510294065]   -0.143046\n",
       "6         hum   [-0.16007614239866622]  [-0.12687929764710046]   -0.154900"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mses = np.mean(lasso.mse_path_, axis = 1)\n",
    "plt.plot(np.log10(lasso.alphas_), mses) \n",
    "#plt.plot(np.log10(lasso.alphas_)*np.ones(3), [0.3, 0.4, 1.0])\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()    \n",
    "            \n",
    "print ('alpha is:', lasso.alpha_)\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(columns), \"coef_lr\":list((lr.coef_.T)), \"coef_ridge\":list((ridge.coef_.T)), \"coef_lasso\":list((lasso.coef_.T))})\n",
    "fs.sort_values(by=['coef_lr'],ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEKCAYAAAD9xUlFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3Xl83HW97/HXJ1vTNd1SuqQrDW2ptFRDAQGFi0DhHqnoFake9eLCPVfRqx4X0CMoHM+Rox6veBUOerkKIogKsvUCVWQRqTRQWro3pFu6JWmaNGmzznzOH/NLmKZJOyn5zW8meT8fj3nM/H6/78zv8+uvmff8ft/fYu6OiIgIQE7UBYiISOZQKIiISBeFgoiIdFEoiIhIF4WCiIh0USiIiEgXhYKIiHRRKIiISBeFgoiIdMmLuoC+Gj9+vM+YMSPqMkREssorr7xS6+7FJ2qXdaEwY8YMysvLoy5DRCSrmNmOVNpp95GIiHQJLRTM7G4zqzazdb1MNzO73cwqzGytmb09rFpERCQ1YW4p/AJYcpzplwOlweM64I4QaxERkRSEFgru/jxQd5wmS4F7PGElMNrMJoVVj4iInFiUfQpTgF1Jw1XBuGOY2XVmVm5m5TU1NWkpTkRkMIoyFKyHcT3e8cfd73L3MncvKy4+4RFVIiJykqIMhS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vbtXubTZGY/MLNXzexPZlacNPmDZvaymW0xswuC9jPM7IWg/atm9s6k9n8IahAJlUJBBqP3A2cCC4H3AN8LrmfzfmAGcAbwKeDcpPecB7ySNPwNdy8DFgDvNrMFPcxnOPCqu78deI6jr5GV5+6LgS8kja8GLgnafwi4Pal9OXBB3xdVpG90QTwZjM4H7nf3GLDfzJ4DzgrG/9bd48A+M/tz0nsmATVJw1cHl6zOC6adTuLSJ8niwG+C178CHkqa1vn6FRJBBJAP/B8zOxOIAaclta8mcXkIkVApFGQw6ulyzccbD9AMFAKY2Uzgy8BZ7n7QzH7ROe0Ekq8p0xo8x3jz7/CLJK4RtJDEVnxLUvvCoAaRUGn3kQxGzwMfMrPcYD//u4CXgb8AHwj6Fk7h6MufbwRmB69HAYeBhqDd5b3MJwfo7JP4cPD5x1ME7A22VD5K4laVnU4je6+EKllEWwoyGD1Mor9gDYlf7191931m9nvgYhJfvluAvwENwXueIBESf3T3NWa2msQVSiuBF3uZz2Fgvpm9EnzOh05Q10+B35vZB4E/B+/vdFFQg0iodJVUkSRmNsLdm8xsHImth/OCwBhK4ov6vKAvIpXPanL3Ef1U1/PAUk/TNUP0AAAAV0lEQVTc81skNNpSEDna42Y2GigAbnX3fQDu3mxmN5O4f/DOdBYU7OL6dwWCpIO2FEREpIs6mkVEpItCQUREuigURESki0JBRES6KBRERKSLQkFERLr8J9yOOjGWaNH0AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 0.004716313265995606\n"
     ]
    }
   ],
   "source": [
    "mses = np.mean(lasso.mse_path_, axis = 1)\n",
    "plt.plot(np.log10(lasso.alphas_), mses) \n",
    "#plt.plot(np.log10(lasso.alphas_)*np.ones(3), [0.3, 0.4, 1.0])\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()    \n",
    "            \n",
    "print ('alpha is:', lasso.alpha_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
